<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // const cart = {
        //     _wheels: 4,

        //     get wheels() {
        //         return this._wheels;
        //     },

        //     set wheels(value) {
        //         if (value < this._wheels) {
        //             throw new Error('数值太小了！');
        //         }
        //         this._wheels = value;
        //     }
        // }
        // cart.wheels = 3
        // console.log(cart.wheels());//显示数值太小了 相当于get和set是内置的

        function strMapToObj(strMap) {
            let obj = Object.create(null);
            for (let [k, v] of strMap) {
                obj[k] = v;
            }
            return obj;
        }

        const myMap1 = new Map()
            .set('yes', true)
            .set('no', false);
        let re = strMapToObj(myMap1)
        console.log(re);
    </script>
</body>

</html>